from django.db import models

# Create your models here.


class Role(models.Model):
    character = models.CharField(max_length=10, null=False, verbose_name='角色')

    def __str__(self):
        return self.character

    class Meta:
        db_table = 'role'
        verbose_name = '角色表'
        verbose_name_plural = verbose_name


class Users(models.Model):
    openid = models.CharField(max_length=100, null=True, verbose_name='ID')
    uphone = models.CharField(max_length=11, null=False, verbose_name='电话')
    role = models.ForeignKey(Role, related_name='userall', verbose_name='身份')

    def __str__(self):
        return self.role.character

    class Meta:
        db_table = 'users'
        verbose_name = '用户表'
        verbose_name_plural = verbose_name


class Openid(models.Model):
    code = models.CharField(max_length=150, null=True, verbose_name='code')
    openid = models.CharField(max_length=150, null=True, verbose_name='openid')
    sessionkey = models.CharField(max_length=100, default=0, verbose_name='sessionkey')    

    def __str__(self):
        return self.code

    class Meta:
        db_table = 'code'
        verbose_name = 'code表'
        verbose_name_plural = verbose_name
